'''
用户登录
输入用户名
输入密码
输入验证码(封装成一个函数)
'''
import random


def generate_checkcode(n):
     s = 'qwertyuiopasdfghjklQWERTYUIOPASDFGHJKL0123456789'
     code = ''
     for i in range(n):
         ran = random.randint(0,len(s)-1)
         code += s[ran]
     return  code

def login():
    username = input('请输入用户名:')
    password = input('请输入密码:')
    code1 = generate_checkcode(4)
    print('验证码是:',code1)
    code2 = input('输入验证码:')
    if code1.lower() == code2.lower():
       if username == 'admin' and password == '123':
           print('用户登录成功！')
       else:
           print('用户名或密码错误！')
    else:
        print('验证码输入有误！')

login()